<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>发送短信</title>
    <style>
      button {
        margin-left: 10px;
      }
    </style>
  </head>
  <body>
    <input type="text" /><button>发送短信</button>
    <script>
      var button = document.querySelector("button");
      button.addEventListener("click", function () {
        this.disabled = true;
        var time = 5;
        this.innerHTML = "过" + time + "s后尝试";
        var timer = setInterval(function () {
          //每1s改变一次内容
          console.log(time);
          button.innerHTML = "过" + --time + "s后尝试";
        }, 1000);
        setTimeout(function () {
          clearInterval(timer);
          button.disabled = false;
          button.innerHTML = "发送短信";
        }, 5000);
      });
    </script>
  </body>
</html>
